import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import * as CounterActions from '../actions/counter';

class Counter extends React.Component{
	constructor(){
		super();
	}

	render(){
		return (
			<div>
				<p>这是一个计数器组件 counter: {this.props.counter} </p>
				<button onClick={this.props.add}>+</button> 
				<button onClick={this.props.inc}>-</button>
			</div>
		)
	}
}

function mapStateToProps(state){
	return {
		counter:state.counter
	}
}
function mapDispatchToProps(dispatch) {
  return bindActionCreators(CounterActions, dispatch);
}

export default connect(mapStateToProps,mapDispatchToProps)(Counter)